// const {app,BrowserWindow} = require('electron')
import {app,screen,BrowserWindow,Tray,nativeImage} from "electron"
import path from "node:path"
import {updateElectronApp} from 'update-electron-app'

app.whenReady().then(()=>{
    const { width, height } = screen.getPrimaryDisplay().bounds; 
    const logo = nativeImage.createFromPath('../public/vite.svg')
    const tray = new Tray(logo)
    updateElectronApp()
    const createWindow = ()=>{
        const mainWin = new BrowserWindow({
            width,
            height,
            webPreferences:{
                nodeIntegration:true,
                preload:path.resolve('./preload.js')
            }
        })
        mainWin.loadURL('http://127.0.0.1:5173/')
        return mainWin
    }
    createWindow()
    app.on('activate', () => {
        if (BrowserWindow.getAllWindows().length === 0) {
          createWindow()
        }
    })
})
app.on('window-all-closed',()=>{
    if (process.platform !== 'darwin') {
        app.quit()
    }
})